using System;
using System.Collections.Generic;
using System.Text;

using DirkRettschlag.Utils;

namespace Departure
{
    public class StationSettings
    {

        #region Variables

        Settings settings;
        string internalName;
        string transfers;
        string transfersSelected;
        string station;
        string stationID;
        string abbreviation;
        bool useTrainsFilter;
        string trainsFilter;
        bool useDirectionsFilter;
        string directionsFilter;
        bool usePlatformsFilter;
        string platformsFilter;
        bool useAndFilter;
        bool useShowPlatform;

        #endregion Variables

        #region Properties

        public string InternalName
        {
            get { return this.internalName; }
            set { this.internalName = value; }
        }

        public string Transfers
        {
            get { return this.transfers; }
            set { this.transfers = value; }
        }

        public string TransfersSelected
        {
            get { return this.transfersSelected; }
            set { this.transfersSelected = value; }
        }

        public string Station
        {
            get { return this.station; }
            set { this.station = value; }
        }

        public string StationID
        {
            get { return this.stationID; }
            set { this.stationID = value; }
        }

        public string Abbreviation
        {
            get { return this.abbreviation; }
            set { this.abbreviation = value; }
        }

        public bool UseTrainsFilter
        {
            get { return this.useTrainsFilter; }
            set { this.useTrainsFilter = value; }
        }

        public string TrainsFilter
        {
            get { return this.trainsFilter; }
            set { this.trainsFilter = value; }
        }

        public bool UseDirectionsFilter
        {
            get { return this.useDirectionsFilter; }
            set { this.useDirectionsFilter = value; }
        }

        public string DirectionsFilter
        {
            get { return this.directionsFilter; }
            set { this.directionsFilter = value; }
        }

        public bool UsePlatformsFilter
        {
            get { return this.usePlatformsFilter; }
            set { this.usePlatformsFilter = value; }
        }

        public string PlatformsFilter
        {
            get { return this.platformsFilter; }
            set { this.platformsFilter = value; }
        }

        public bool UseAndFilter
        {
            get { return this.useAndFilter; }
            set { this.useAndFilter = value; }
        }

        public bool UseShowPlatform
        {
            get { return this.useShowPlatform; }
            set { this.useShowPlatform = value; }
        }

        #endregion Properties

        #region Constructor

        public StationSettings(string internalName, Settings settings)
        {
            this.internalName = internalName;
            this.settings = settings;
        }

        #endregion Constructor

        #region Public Methods

        public void getSettings()
        {
            //settings = new Settings(Utilities.AppPath() + "\\settings.xml");
            settings.Filename = Utilities.AppPath() + "\\settings.xml";
            this.station = this.settings.ReadString(this.internalName, "Station", "");
            this.stationID = this.settings.ReadString(this.internalName, "StationID", "");
            this.abbreviation = this.settings.ReadString(this.internalName, "Abbreviation", "");
            this.transfers = this.settings.ReadString(this.internalName, "Transfers", "000000000000");
            this.transfersSelected = this.settings.ReadString(this.internalName, "TransfersSelected", "000000000000");
            this.useTrainsFilter = this.settings.ReadBool(this.internalName, "useTrainsFilter", false);
            this.TrainsFilter = this.settings.ReadString(this.internalName, "TrainsFilter", "");
            this.useDirectionsFilter = this.settings.ReadBool(this.internalName, "useDirectionsFilter", false);
            this.directionsFilter = this.settings.ReadString(this.internalName, "DirectionsFilter", "");
            this.usePlatformsFilter = this.settings.ReadBool(this.internalName, "usePlatformsFilter", false);
            this.platformsFilter = this.settings.ReadString(this.internalName, "PlatformsFilter", "");
            this.useAndFilter = this.settings.ReadBool(this.internalName, "useAndFilter", false);
            this.useShowPlatform = this.settings.ReadBool(this.internalName, "useShowPlatform", true);
        }

        public void saveSettings()
        {
            //settings = new Settings(Utilities.AppPath() + "\\settings.xml");
            settings.Filename = Utilities.AppPath() + "\\settings.xml";
            this.settings.WriteString(this.internalName, "Station", this.station);
            this.settings.WriteString(this.internalName, "StationID", this.stationID);
            this.settings.WriteString(this.internalName, "Abbreviation", this.abbreviation);
            this.settings.WriteString(this.internalName, "Transfers", this.transfers);
            this.settings.WriteString(this.internalName, "TransfersSelected", this.transfersSelected);
            this.settings.WriteBool(this.internalName, "useTrainsFilter", this.useTrainsFilter);
            this.settings.WriteString(this.internalName, "TrainsFilter", this.trainsFilter);
            this.settings.WriteBool(this.internalName, "useDirectionsFilter", this.useDirectionsFilter);
            this.settings.WriteString(this.internalName, "DirectionsFilter", this.directionsFilter);
            this.settings.WriteBool(this.internalName, "usePlatformsFilter", this.usePlatformsFilter);
            this.settings.WriteString(this.internalName, "PlatformsFilter", this.platformsFilter);
            this.settings.WriteBool(this.internalName, "useAndFilter", this.useAndFilter);
            this.settings.WriteBool(this.internalName, "useShowPlatform", this.useShowPlatform);

            this.settings.Save();
        }

        public void removeSettings()
        {
            //settings = new Settings(Utilities.AppPath() + "\\settings.xml");
            settings.Filename = Utilities.AppPath() + "\\settings.xml";
            this.settings.RemoveSection(this.internalName);
            this.settings.Save();
        }

        #endregion Public Methods

    }
}
